× Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6 Lesson 7 Lesson 8 Lesson 9 Lesson 10 Lesson 11

All lessons

☰ open

Mini Lesson 2: Importing Modules

Modules are very important in programming. Which modules that you import into Python are up to you, and they can add certain functions and classes. There are also plenty of built in modules, for example the print() function is one of the built in modules in Python. Here is the basic syntax for importing a module into Python:

import math

With this simple code, we gained access to a wide variety of functions from the math module, such as gcd(), which finds the greatest common divisor of two numbers, and log(), which returns the log of a selected base of a number.

To find all available modules, simply look up "Python 3 modules" and you not only find available modules but also all of the avaiable functions/methods.